home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_313 / uucp / uucp1.lzh / src / lib / seq.c < prev    next >
C/C++ Source or Header  |  1990-01-14  |  643b  |  44 lines

  1.  
  2. /*
  3.  *  SEQ.C
  4.  *
  5.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  6.  *
  7.  *  Returns a unique sequence number
  8.  */
  9.  
  10. #include <stdio.h>
  11.  
  12. GetSequence(bump)
  13. {
  14.     char *seqfile = "UULIB:seq";
  15.     FILE *fp;
  16.     int seq;
  17.     char buf[32];
  18.  
  19.     LockFile(seqfile);
  20.     fp = fopen("UULIB:seq","r");
  21.     if (fp) {
  22.     fgets(buf, 32, fp);
  23.     seq = atoi(buf);
  24.     fclose(fp);
  25.     } else {
  26.     perror("UULIB:seq");
  27.     seq = -1;
  28.     }
  29.  
  30.     if (seq > 0) {
  31.     fp = fopen("UULIB:seq", "w");
  32.     if (fp) {
  33.         fprintf(fp,"%d", seq + bump);
  34.         fclose(fp);
  35.     } else {
  36.         perror("UULIB:seq");
  37.         seq = -1;
  38.     }
  39.     }
  40.     UnLockFile(seqfile);
  41.     return(seq);
  42. }
  43.  
  44.